package org.singledog.form.builder.parser.freemarker;

import org.singledog.form.builder.parser.freemarker.freemarker.FreeMarkerConfiguration;
import org.springframework.util.Assert;

public class FreemarkerFormParserConfiguration {

    public static FreemarkerFormParserConfiguration getInstance() {
        return new FreemarkerFormParserConfiguration();
    }

    public FreemarkerFormParserConfiguration configSchemaDirectory(String directory) {
        Assert.notNull(directory, "config schema directory can not be null !");
        if (!directory.endsWith("/")) {
            directory = directory.concat("/");
        }
        FreeMarkerContants.setBaseSchemaDirectory(directory);
        return this;
    }

    public FreemarkerFormParserConfiguration useCache(boolean useCache) {
        FreeMarkerConfiguration.setUseCache(useCache);
        return this;
    }

}
